<template>
<div style="width: 100%">
  <a-card class="card" :bordered="false">
    <div class="table-page-search-wrapper">
      <a-form layout="vertical">
        <a-row :gutter="48">
          <a-col :sm="{span:12}" :lg="{span:6}" :xl="{span:6}" >
            <a-form-item label="院系">
              <a-select :allowClear="true" showSearch optionFilterProp="children" v-model="queryParam.ssyxm" @change="yxChange">
                <a-select-option v-for="i in selectMenu.yx" :key="i.id" :value="i.dwh">{{ i.dwmc }}</a-select-option>
              </a-select>
            </a-form-item>
          </a-col>
          <a-col :sm="{span:12}" :lg="{span:6}" :xl="{span:6}">
            <a-form-item label="专业">
              <a-select :allowClear="true" showSearch optionFilterProp="children" v-model="queryParam.zy">
                <a-select-option v-for="i in TYPE0126" :key="i.id" :value="i.code">{{ i.name }}</a-select-option>
              </a-select>
            </a-form-item>
          </a-col>
           <template v-if="advanced">
          <a-col :sm="{span:24}" :lg="{span:6}" :xl="{span:6}">
            <a-form-item label="招生年度">
              <a-select :allowClear="true" showSearch optionFilterProp="children" v-model="queryParam.sznj">
                <a-select-option v-for="i in TYPE0126" :key="i.id" :value="i.code">{{ i.name }}</a-select-option>
              </a-select>
            </a-form-item>
          </a-col>
           </template>
          <a-col :sm="{span:16}" :xl="{span:8}">
            <a-button type="primary" @click="loadData">查询</a-button>
            <a-button type="primary" @click="handleExport">导出</a-button>
            <a @click="advanced = !advanced" style="margin-left: 8px">
                {{ advanced ? '收起' : '展开' }}
                <a-icon :type="advanced ? 'up' : 'down'"/>
              </a>
          </a-col>
        </a-row>
      </a-form>
    </div>
    </a-card>
    <a-card class="card" :bordered="false">
    <a-table
      ref="table"
      size="default"
      rowKey="key"
      :columns="columns"
      :loading="loading"
      :dataSource="data"
      :pagination="false"
    >
      <span slot="serial" slot-scope="text, record, index">
        {{ index + 1 }}
      </span>
    </a-table>
    </a-card>
</div>
</template>

<script>
// import moment from 'moment'
import { STable } from '~'
import { mapState } from 'vuex'

const selectArr = ['TYPE0126', 'TYPE0075', 'TYPE0125', 'TYPE0072']

export default {
  components: {
    STable
  },
  data () {
    return {
      advanced: true,
      loading: false,
      data: [],
      // 查询参数
      queryParam: {
        hzfs: 'yx'
      },
      postParams: {},
      // 表头
      columns: [
        {
          title: '序号',
          scopedSlots: { customRender: 'serial' }
        },
        {
          title: '准考证号',
          dataIndex: 'zkzh'
        },
        {
          title: '姓名',
          dataIndex: 'xm'
        },
        {
          title: '报考院系',
          dataIndex: 'bkyx'
        },
        {
          title: '报考专业',
          dataIndex: 'bkzy'
        },
        {
          title: '研究方向',
          dataIndex: 'yjfx'
        },
        {
          title: '科目一',
          dataIndex: 'kmy'
        },
        {
          title: '科目二',
          dataIndex: 'kme'
        },
        {
          title: '科目三',
          dataIndex: 'kmsan'
        },
        {
          title: '科目四',
          dataIndex: 'kms'
        },
        {
          title: '总分',
          dataIndex: 'zf'
        }
      ],
      selectMenu: {
        yx: [] // 院系
      }
    }
  },
  computed: {
    ...mapState({
      systemInfo: state => state.app.systemInfo,
      TYPE0126: state => state.app['TYPE0126'] // 年级
    })
  },
  created () {
    this.initSelectMenu()
    this.loadData()
    selectArr.forEach(v => {
      this.$store.dispatch('app/setDictionary', v)
    })
  },
  methods: {
    initSelectMenu () {
      let allRequest = [
        this.$api.base.collegeAll()
      ]
      Promise.all(allRequest).then(res => {
        this.selectMenu = {
          yx: res[0].data
        }
      })
    },
    // 选择院系
    yxChange (code) {
    },
    // 加载数据
    loadData () {
      return new Promise(resolve => { resolve() }).then(res => {
        this.data = [{
          zkzh: 'A001',
          xm: '章鱼',
          bkyx: '电子院',
          bkzydm: 'what',
          bkzy: '计算机',
          yjfx: 'AI',
          kmy: '100',
          kme: '80',
          kmsan: '80',
          kms: '99',
          zf: '300',
          key: 1
        }, {
          zkzh: 'A001',
          xm: '章鱼',
          bkyx: '电子院',
          bkzydm: 'what',
          bkzy: '计算机',
          yjfx: 'AI',
          kmy: '100',
          kme: '80',
          kmsan: '80',
          kms: '99',
          zf: '300',
          key: 12
        }, {
          zkzh: 'A001',
          xm: '章鱼',
          bkyx: '电子院',
          bkzydm: 'what',
          bkzy: '计算机',
          yjfx: 'AI',
          kmy: '100',
          kme: '80',
          kmsan: '80',
          kms: '99',
          zf: '300',
          key: 18
        }]
      })
    },
    // 生成
    handleExport () {}
  }
}
</script>

<style lang="less" scoped>
.card{
  margin-bottom: 20px;
}
</style>
